'use strict';

const { Controller } = require('egg');

const path = require('path')
const fs = require('fs')
class HomeController extends Controller {
  async index() {
    const { ctx } = this;
    const { url } = ctx.params;
    const filepath = path.resolve(__dirname, '../static', url)
      
    const exist = fs.existsSync(filepath);
    if (exist) {
      ctx.body = fs.readFileSync(filepath);
    } else {
      ctx.status = 404
      ctx.body = '404 notFound'
    }

  }
}

module.exports = HomeController;
